﻿
@{
    ViewBag.Title = "添加商品";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@using Mate.Framework.Extensions
@model Mate.Dto.Good.GoodModel
@section styles{

}
@section scripts{
    <script src="~/bootstrap/plugins/jquery-validation/dist/jquery.validate.min.js"></script>
    <script src="~/bootstrap/plugins/jquery-validation/dist/additional-methods.min.js"></script>
    <script src="~/bootstrap/scripts/custom/form-validation.js" charset="gbk"></script>

    <script src="~/plugins/ueditor-1.4.3.3/ueditor.config.js"></script>
    <script src="~/plugins/ueditor-1.4.3.3/ueditor.all.js"></script>

    <script src="~/js/admin.js?v=1.0"></script>
    <script language="javascript" type="text/javascript">
        $(function () {
            var rules = {
                name: {
                    required: true
                },
                title: {
                    required: true
                },
                describe: {
                    required: true
                },
                content: {
                    required: true
                },
                price: {
                    required: true,
                    number: true
                },
                discount: {
                    required: true,
                    number: true
                }
            };
            FormValidation.BasicValidation(rules);

        });
        var ue = UE.getEditor('content');
    </script>
}

<ul class="page-breadcrumb breadcrumb">
    <li>
        <a href="@Url.Action("Index","Good")">
            商品管理
        </a>
        <i class="fa fa-angle-right"></i>
    </li>
    <li>
        添加商品
    </li>
</ul>

<div class="row">
    <div class="col-md-12">

        <div class="portlet-body form">
            <!-- BEGIN FORM-->
            @using (Html.BeginForm("Create", "Good", FormMethod.Post, new { @class = "form-horizontal", @id = "form_ff_validation", @novalidate = "novalidate" }))
            {
            <div class="form-body">
                @Html.TextFor("商品名称", "name", value: Model.name)
                @Html.TextFor("商品标题", "title", value: Model.title)
                <div class="form-group">
                    <label class="control-label col-xs-3">
                        商品分类
                        <span class="required">*</span>
                    </label>
                    <div class="col-xs-4">
                        <select id="categoryid" name="categoryid" class="form-control">
                            @if (Model.GoodCategoryList != null)
                            {
                                var list = Model.GoodCategoryList as IList<Mate.Dto.Good.GoodCategoryTreeModel>;
                                var parentList = list.Where(x => x.parentid == 0).ToList();
                                foreach (var item in parentList)
                                {
                                    <option value="@(item.id)">@item.name</option>
                                    if (item.children.Any())
                                    {
                                        foreach (var item2 in item.children)
                                        {
                                            <option value="@(item2.id)">├── @item2.name</option>
                                        }
                                    }
                                }
                            }
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-3">
                        所属商家
                        <span class="required">*</span>
                    </label>
                    <div class="col-xs-4">
                        <select id="merchantid" name="merchantid" class="form-control">
                            @if (Model.MerchantList != null)
                            {
                                var list = Model.MerchantList as IList<Mate.Db.Model.Merchant.mp_merchant>;
                                foreach (var item in list)
                                {
                                    <option value="@(item.id)">@item.merchantname</option>
                                }
                            }
                        </select>
                    </div>
                </div>
                @Html.TextFor("商品描述", "describe", value: Model.describe)
                @Html.TextFor("商品价格", "price")
                @Html.TextFor("折扣", "discount")
                @Html.TextFor("备注", "remark", value: Model.remark)
                @Html.RadioFor("审核状态", "is_audit", new List<KeyValuePair<string, string>>()
                                                    {
                                                        new KeyValuePair<string, string>("1","审核"),
                                                        new KeyValuePair<string, string>("2","审核中"),
                                                        new KeyValuePair<string, string>("3","审核不通过")
                                                    },selectValue:Model.is_audit?.ToString())

                @Html.EditorFor("商品详情", "content", value: Model.content, inputWidth: 8)

            </div>

                <div class="form-actions fluid">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn green" type="button" onclick="admin.AddSubmit('@Url.Action("Index")')"> 提交 <i class="fa fa-check"></i> </button>
                        <a class="btn default" role="button" href="@Url.Action("Index")"> 返回 <i class="fa fa-reply"></i></a>
                    </div>
                </div>
            }
            <!-- END FORM-->
        </div>
    </div>
    <!-- END VALIDATION STATES-->
</div>
